var util = require('./utils/util.js');
var api = require('./config/api.js');
var user = require('./services/user.js');

App({
  onLaunch: function() {
    //获取用户的登录信息
    user.checkLogin().then(res => {
      console.log('小程序登录成功！')
      this.globalData.userInfo = wx.getStorageSync('userInfo');
      this.globalData.token = wx.getStorageSync('token');
    }).catch(() => {
      wx.removeStorageSync('userInfo');
      wx.removeStorageSync('token');
    });
  },

  globalData: {
    userInfo: {
      nickName: '登录/注册',
      userName: '点击去登录',
      avatarUrl: 'http://shop.nnsirui.com/images/app/userimg.png'
    },
    token: '',
    user_id: 0,
    inviter_info: {},
    //userCoupon: 'NO_USE_COUPON',// 
    //courseCouponCode: {},// 
  }
})